package com.hc.model.code04.test7;

/**
 * @version v1.0
 * @ClassName: MediatorStructure
 * @Description: 具体的中介接口实现
 * @Author: HC
 */
public class MediatorStructure extends Mediator{

    // 聚合房主和租房者对象
    private HouseOwner houseOwner;
    private Tenant tenant;

    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    @Override
    public void contact(String message, Person person) {
        // 判断
        // 如果是房主，就跟租房者沟通
        if (person == houseOwner) {
            tenant.getMessage(message);
        } else {
            // 否则就跟房主沟通
            houseOwner.getMessage(message);
        }
    }
}
